import Bean.FileBean;
import Mapper.FileSqlOperationMapper;
import Utils.Dateoperation;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

public class TEST {
    public static void main(String[] args) {

        String resource = "mybatis-config.xml";
        InputStream inputStream = null;
        try {
            inputStream = Resources.getResourceAsStream(resource);
        } catch (IOException e) {
            e.printStackTrace();
        }
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession(true);
        FileSqlOperationMapper fileOperation = sqlSession.getMapper(FileSqlOperationMapper.class);
        List<FileBean> list=fileOperation.selectAll();
        System.out.println(list);
        for (FileBean fileBean:list){
            System.out.println(fileBean.toString());
        }
        int order=fileOperation.getOrder();
        System.out.println(order);

        FileBean fileBean = new FileBean();

//        Date creatTime =tempTime.toLocal;

/*UUID一般不做过多处理，涉及重复的可能性
        int uuid = UUID.randomUUID().hashCode();
        if (uuid < 0) {
            uuid = -uuid;
        }
*/
/*//            插入操作
        fileBean.setId(Integer.parseInt(String.format("%08d", UUID.randomUUID().hashCode())));
        fileBean.setFileUrl("/stores/file/test");
        fileBean.setClassUrl("as/sdqw");
        Dateoperation date =new Dateoperation();
        try {
            fileBean.setCreatTime(date.getcurrentTime());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        fileBean.setName("a.jpg");
        fileBean.setSize(200);
        fileBean.setStatus(0);
        fileBean.setType("png");

        fileOperation.insert(fileBean);*/
        sqlSession.close();
    }
}
